//
//  DatabaseView
//
//  Created by Caue W. on 2011-03-28.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
package time.types.query;
import haxe.Prelude;

class DatabaseView<K,V>
{
	function all(?start:Int = 0, ?limit:Int = -1):Array<V>;
	function allKV(?start:Int = 0, ?limit:Int = -1):Array<{key:K, value:V}>;
	
	function range(start:K, end:K, ?paginationStart = 0, ?limit = -1):Array<V>;
	
	//In a DatabaseView, every get() call will result in a database call. Use with care!
	function get(key:K):Null<V>;
	//NOT RECOMMENDED! It's best to have a DatabaseView specially for this
	function length():Int; 
	
	function isTransactional() : Bool;
}

class AsyncDatabaseView<K, V>
{
	function all(?start:Int = 0, ?limit:Int = -1):Future<Array<V>>;
	function allKV(?start:Int = 0, ?limit:Int = -1):Future<Array<{key:K, value:V}>>;
	
	function range(start:K, end:K, ?paginationStart = 0, ?limit = -1):Future<Array<V>>;
	function get(key:K):Future<Null<V>>;
	
	function length():Future<Int>; // NOT RECOMENDED! It's best to have a DatabaseView specially for this
	
	function isTransactional() : Bool;
}